//
//  ViewController.swift
//  videoplayer
//
//  Created by 谢 on 2019/8/15.
//  Copyright © 2019 谢. All rights reserved.
//

import UIKit
import AVKit
import AVFoundation

class ViewController: UIViewController {

    @IBOutlet weak var textField: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    @IBAction func btn(_ sender: Any) {
        let textValue = textField.text
        let streamUrl = textValue!
//        let streamUrl = "https://livesec.mudu.tv/watch/rupvwq.m3u8?auth_key=1566354399-655874-0-d2676fc773de97bd7af97d5f45724a5f"
        // "http://myun-hw-s3.myun.tv/n856xo5m/1535512040681946728_284_480p.m3u8"
        guard let url = URL(string: streamUrl) else {
            return
        }
        
        let player = AVPlayer(url: url)
        
        let controller = AVPlayerViewController()
        controller.player = player
        
        present(controller, animated: true) {
            player.play()
        }
    }
    
}

